/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:hadss_adaptive_layout/hadss_adaptive_layout.dart';

import '../../../l10n/generated/app_localizations.dart';

class Entrances extends StatefulWidget {
  final WidthBreakpoint screenType;
  final num currentWidth;

  final List  entrancesList = [
    'lib/assets/images/entrances/grid_item_entrances_icon_0.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_1.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_2.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_3.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_4.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_5.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_6.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_7.png',
    'lib/assets/images/entrances/grid_item_entrances_icon_8.png',
  ];

  Entrances(
      {Key? key, required this.currentWidth, required this.screenType})
      : super(key: key);

  @override
  State<Entrances> createState() => _EntrancesState();
}

class _EntrancesState extends State<Entrances> {
  @override
  Widget build(BuildContext context) {
    AppLocalizations il8n = AppLocalizations.of(context)!;
    double marginValue = widget.screenType == WidthBreakpoint.sm ||
            widget.screenType == WidthBreakpoint.xs
        ? 13
        : widget.screenType == WidthBreakpoint.lg
            ? 60
            : 50;


    final List  entrancesList = [
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_0.png',
        "name": Text(il8n.all)
      },
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_1.png',
        "name": Text(il8n.zhouHotList)
      },
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_2.png',
        "name": Text(il8n.free)
      },
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_3.png',
        "name": Text(il8n.classic)
      },
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_4.png',
        "name": Text(il8n.membersZone)
      },{
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_5.png',
        "name": Text(il8n.childrenZone)
      },{
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_6.png',
        "name": Text(il8n.liveCommerce)
      },
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_7.png',
        "name": Text(il8n.all)
      },
      {
        "url":'lib/assets/images/entrances/grid_item_entrances_icon_8.png',
        "name": Text(il8n.all)
      },

    ];

    return Container(
        width: widget.currentWidth * 1.0,
        margin: const EdgeInsets.only(top: 20),
        child: ScrollConfiguration(
            behavior: ScrollConfiguration.of(context).copyWith(
              dragDevices: {
                PointerDeviceKind.touch,
                PointerDeviceKind.mouse,
                PointerDeviceKind.trackpad,
              },
            ),
            child: SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                child: Row(children: entrancesList.map((item) {
                  return Container(
                    margin: EdgeInsets.fromLTRB(20, 0, marginValue, 0),
                    child: Column(
                      children: [
                        Container(
                            width: 40,
                            height: 40,
                            margin: const EdgeInsets.only(bottom: 5),
                            child: Image.asset(item["url"]),),
                            item["name"]
                      ],
                    ),
                  );
                }).toList()
                ))));
  }
}
